package com.mayuhao.userstudent.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mayuhao.userstudent.config.SchedulingConfig;
import com.mayuhao.userstudent.entity.UserStudent;
import com.mayuhao.userstudent.service.IUserStudentService;
import com.mayuhao.userstudent.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 马宇豪
 * @since 2022-10-27
 */
@RestController
//@RequestMapping("/css-course")
public class UserStudentController {
    @Resource
    private IUserStudentService studentService;

    @Resource
    private SchedulingConfig schedulingConfig;

    /**
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.mayuhao.userstudent.entity.UserStudent>
     * @description 请修改方法描述
     * @methodName findPage
     * @params [pageNum, pageSize, searchId, searchName]
     * @paramType [java.lang.Integer, java.lang.Integer, java.lang.String, java.lang.String]
     * @author 马宇豪
     * @date 2022/10/27 0027 下午 1:28
     * @email 1757442521@qq.com
     **/

    @GetMapping("/findpage")
    public Page<UserStudent> findPage(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "7") Integer pageSize,
            @RequestParam(defaultValue = "") String searchId,
            @RequestParam(defaultValue = "") String searchName) {
        return studentService.findPage(pageNum, pageSize, searchId, searchName);
    }

    /**
     * @return boolean
     * @description 请修改方法描述
     * @methodName chooseCourse
     * @params [courseId]
     * @paramType [java.lang.Integer]
     * @author 马宇豪
     * @date 2022/10/27 0027 下午 4:29
     * @email 1757442521@qq.com
     **/
    @PutMapping("/choosecourse/{studentId}/{courseId}")
    public boolean chooseCourse(@PathVariable String studentId, @PathVariable String courseId) {
        studentService.saveChooseCourse(studentId, courseId);
        return studentService.chooseCourse(courseId);
    }


    /**
     * @return boolean
     * @description 请修改方法描述
     * @methodName returnCourse
     * @params [courseId]
     * @paramType [java.lang.Integer]
     * @author 马宇豪
     * @date 2022/10/27 0027 下午 4:44
     * @email 1757442521@qq.com
     **/
    @PutMapping("/returncourse/{studentId}/{courseId}")
    public boolean returnCourse(@PathVariable String studentId, @PathVariable String courseId) {
        studentService.deleteChooseCourse(studentId, courseId);
        return studentService.returnCourse(courseId);
    }


    /**
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.mayuhao.userstudent.entity.UserStudent>
     * @description 请修改方法描述
     * @methodName hasChoosePage
     * @params [pageNum, pageSize, searchId, searchName]
     * @paramType [java.lang.Integer, java.lang.Integer, java.lang.String, java.lang.String]
     * @author 马宇豪
     * @date 2022/10/31 0031 上午 8:43
     * @email 1757442521@qq.com
     **/
    @GetMapping("/haschoosepage")
    public Page<UserStudent> hasChoosePage(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "7") Integer pageSize,
            @RequestParam(defaultValue = "1") String studentId,
            @RequestParam(defaultValue = "") String searchId,
            @RequestParam(defaultValue = "") String searchName) {
        return studentService.hasChoosePage(pageNum, pageSize, studentId, searchId, searchName);
    }


    /**
     * @return boolean
     * @description 请修改方法描述
     * @methodName selectBeforeChoose
     * @params [studentId, courseId]
     * @paramType [java.lang.String, java.lang.String]
     * @author 马宇豪
     * @date 2022/11/10 0010 上午 12:42
     * @email 1757442521@qq.com
     **/
    @GetMapping("/selectbeforechoose/{studentId}/{courseId}/{courseName}/{goCourseTime}")
    public Result selectBeforeChoose(@PathVariable String studentId, @PathVariable String courseId, @PathVariable String courseName, @PathVariable String goCourseTime) {
        return studentService.selectBeforeChoose(studentId, courseId, courseName, goCourseTime);
    }

    /**
     * @return com.mayuhao.userstudent.util.Result
     * @description 请修改方法描述
     * @methodName scheduleSelect
     * @params []
     * @paramType []
     * @author 马宇豪
     * @date 2022/11/13 0013 下午 6:48
     * @email 1757442521@qq.com
     **/
    @GetMapping("/scheduleselect")
    public Result scheduleSelect() {
//        return new Result(true, "no", schedulingConfig.getToken());
        return new Result(true, "no", null);
    }


}
